using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Xml;

namespace Send2Sharepoint.Forms
{
    public class CheckBoxControl:InputControl
    {
        public CheckBoxControl(XmlNode element) : base(element)
        {
            var attributeCollection = element.Attributes;
            var defaultNode = (from xmlNode in element.ChildNodes.Cast<XmlNode>()
                               where xmlNode.Name == "Default"
                               select xmlNode).SingleOrDefault();

            string defaultValue = defaultNode != null ? defaultNode.InnerText : "";
            var name = attributeCollection["Name"].Value;
            Field = new CheckBox
            {
                Text = "",
                Name = "controlYesNo_" + name,
                Checked = Convert.ToBoolean(Convert.ToInt32(defaultValue))
            };
        }
    }
}